package com.manage.competition.service.impl;

import com.manage.competition.entity.AdvertisePicture;
import com.manage.competition.mapper.AdvertisePictureMapper;
import com.manage.competition.repository.AdvertisePictureRepository;
import com.manage.competition.service.IAdvertisePictureService;
import com.manage.competition.util.CurrentUserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Create with IDEA
 *
 * @Author: gitee.com/KamisamaXX
 * @Date: Create in 0:03 2019/3/28
 * @Description:
 */
@Service
public class AdvertisePictureServiceImpl extends BaseServiceImpl implements IAdvertisePictureService{

    @Autowired
    private AdvertisePictureMapper advertisePictureMapper;

    @Autowired
    AdvertisePictureRepository advertisePictureRepository;

    @Override
    public Integer insert(AdvertisePicture advertisePicture) {
        advertisePicture.setCreateUser(CurrentUserUtil.getCurrentUser().getUsername());
        advertisePicture.setUpdateUser(CurrentUserUtil.getCurrentUser().getUsername());
        return advertisePictureMapper.insert(advertisePicture);
    }

    @Override
    public int updateByPrimaryKey(AdvertisePicture advertisePicture) {
        advertisePicture.setUpdateUser(CurrentUserUtil.getCurrentUser().getUsername());
        return advertisePictureMapper.updateByPrimaryKey(advertisePicture);
    }

    @Override
    public AdvertisePicture findById(Long id) {
        return advertisePictureRepository.findById(id).orElse(null);
    }

    @Override
    public int deleteByPrimaryKey(Long advertisePictureId) {
        return advertisePictureMapper.deleteByPrimaryKey(advertisePictureId);
    }

}
